library(ggplot2)
library(readstata13)

setwd("D:/Dropbox/Distinction Effect/Replication Package/Results/Online Appendix/")

# Gradient color
#library(wesanderson)
#pal <- wes_palette("Zissou1", 10, type = "continuous")
#pal <- c("white", pal)

library(RColorBrewer)
pal <- hcl.colors(10, "YlGnBu")
pal <- c("white", pal[8:2])

df <- read.dta13("Data/Matrix Field-Exam.dta")

png(file="Field-SpecificExam.png", width=1600, height=1400)

ggplot(df, 
  aes(x = fieldname, y = exam_field, fill = share)) + 
  geom_tile(color = "grey") +
  scale_fill_gradientn(colors = pal) +
  theme_bw() + labs(x="Major (Field of Study)", y="Field-Specific Exam", title="") +
  theme(legend.title = element_blank() ,
        axis.text.x=element_text(size=26, angle=90, hjust = 1, vjust = 0.5),
        axis.text.y=element_text(size=26, angle=0),
        axis.title.x=element_text(size=30, vjust = -1.1),
        axis.title.y=element_text(size=30, vjust = 1.1),
        legend.key.size = unit(2, 'cm'), legend.text = element_text(size=24)) +
  coord_equal()

dev.off()
